<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新增省公司合同管理员配置</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<form id="formSet1">
		<div class="fieldset1 tabel_col clearFix">
			<div class="fieldBox col_100">
				<div class="label">省公司合同管理员 </div>
				<div class="field">
				（<input type="checkbox" id="selectAllBtn" onchange="selectAll(this,'userIds');"/>全选）
					<c:forEach items="${localContList}" var="item">
						<input  class="userIdsClass"   name="userIds" <c:if test="${item.isHide}"> checked </c:if> validate="{required:true}"  type="checkbox"  value="${item.key}">${item.value} <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 
					</c:forEach>
				</div>
			</div>
		   <div class="fieldBox col_100">
				<div class="label"> </div>
				<div class="field">
				</div>
			</div>
			<br/>
			<div class="fieldBox col_100">
				<div class="label">所在地</div>
				<div class="field">
					<c:forEach items="${localCityList}" var="item">
						<input  class="cityClass"   name="belongCity" <c:if test="${contVO.belongCity== item.key }"> checked</c:if>   type="radio"  value="${item.key}">${item.value} <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> 
					</c:forEach>
				</div>
			</div>
			<input id="orgId" name="orgId" value="${orgId}" style="display:none">
			<input id="orgCd" name="orgCd" value="${orgCd}" style="display:none">
		</div>
</form>
</div>


<script type="text/javascript">
	var id = '${id}';
	var orgId = '${orgId}';
	var orgCd = '${orgCd}';
	$(function(){
	   var formSet1 = $('#formSet1').ligerForm({
			validate : true
		});
	   initSelectAll();//如果全选了初始化
	   //initData();
	});
	//定义父级调用事件
	frameElement.dialog.onOk = function () {
	     save();
	}
	           
	frameElement.dialog.onCancel = function () {
	     frameElement.dialog.close();
	}
	
	function save(){
		var form = liger.get("formSet1");
	    if (!form.valid()) {
	    	$.ligerDialog.SQalert({content: "省公司合同管理员未选择" , SQ_type: "warning" });
	        return false; //验证不通过，不执行以下代码
	    }
	    var data = form.getData();
	    var url = '<%=path%>/archive/arcLocalContractUser/add.do';
	    if(id != ""){
	    	url = '<%=path%>/archive/arcLocalContractUser/modify.do';
	    	data["id"]= id;
	    }
	    var belongCityVal = $('input:radio[name="belongCity"]:checked').val();
	    if(belongCityVal=='undefined' || belongCityVal=='' || belongCityVal == null){
	    	$.ligerDialog.SQalert({content: "所在地未选择!" , SQ_type: "warning" });
	    	return ;
    	} 
	    
	    data["orgId"]=orgId;
	    data["orgCd"]=orgCd;
	    console.log(data);
	    
	    var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 parent.grid.reload();
					 parent.$.ligerDialog.close();
					 parent.$(".l-dialog,.l-window-mask").css("display","none"); 
					 parent.$("#addBtn").hide();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}

	function selectAll(thisObj,targetCheckbox) {
		if(thisObj.checked) {//全选
			$("input[name='"+targetCheckbox+"']").attr('checked',true);
			$("input[name='"+targetCheckbox+"']").siblings('a').addClass("l-checkbox-checked");
		}else {//全部取消
			$("input[name='"+targetCheckbox+"']").attr('checked',false);
			$("input[name='"+targetCheckbox+"']").siblings('a').removeClass("l-checkbox-checked");
		}
	}
	function initSelectAll(){
	//selectAllBtn
		//$('.conditionClass').find
	}
</script>
</body>
</html>
